using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

using GonzalesCore.CoreManagers;
using GonzalesCore.CoreElements;

using Kypris2.Utils;
using Kypris2.CoreElements;
using Kypris2.CoreManagers;

using Jamila2.CoreElements;
using Jamila2.Tools;

public class ReportsGenerator : ManagerBase
{    
    private PersonalSessionAccount CurrentModuleSession = null;
    private LogManager CurrentLogManager = null;

    public ReportsGenerator(PersonalSessionAccount PrivateConfig)
        : base(PrivateConfig)
	{
        this.CurrentModuleSession = PrivateConfig;
        this.CurrentLogManager = new LogManager(PrivateConfig);
    }

    #region GetClaimantReportsByCompany
    public DataTable GetClaimantReportsByCompany(string CompanyID)
    {
        DataTable ResultTable = null;

        using (UserManager CurManager = new UserManager(this.CurrentModuleSession))
        {
            SystemUsers ResultObj = CurManager.GetUsersByCompany(CompanyID);

            if (ResultObj != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("EmployeeID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ActiveDirectoryID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("DisplayName", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("CostCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ApprovingCurrency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ApprovingLimit", Type.GetType("System.Decimal")));
                //ResultTable.Columns.Add(new DataColumn("ApprovingLimitInStr", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("StopFlag", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ApprovingRouting", Type.GetType("System.String")));

                for (int x = 0; x < ResultObj.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();

                    ResultRow["EmployeeID"] = ResultObj[x].EmployeeID;
                    ResultRow["ActiveDirectoryID"] = ResultObj[x].EmailID;
                    ResultRow["DisplayName"] = ResultObj[x].DisplayName;
                    ResultRow["CostCenter"] = ResultObj[x].CostCenter;
                    ResultRow["ApprovingCurrency"] = (ResultObj[x].ApprovingCurrency != null) ? ResultObj[x].ApprovingCurrency.InternalID : "";
                    ResultRow["ApprovingLimit"] = (ResultObj[x].ApprovingCurrency != null) ? ResultObj[x].ApprovingLimit : 0;
                    //ResultRow["ApprovingLimitInStr"] = (ResultObj[x].ApprovingCurrency != null) ? ResultObj[x].ApprovingLimit.ToString() : "";
                    ResultRow["StopFlag"] = ((ResultObj[x].ApprovalCheckPoint) ? "Yes" : "");
                    ResultRow["ApprovingRouting"] = ClaimManager.GetApprovingRoute(ResultObj[x].AppRoute);

                    ResultTable.Rows.Add(ResultRow);
                }

            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetClaimantReportsByCompany] : CurManager.GetUsersByCompany('" + CompanyID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion

    #region GetActiveExpenseDetailByEntity
    public DataTable GetActiveExpenseDetailByEntity(Language LanguageInUsed, string EntityID)
    {
        DataTable ResultTable = null;

        using (GLClaimTypeManager CurManager = new GLClaimTypeManager(this.CurrentModuleSession))
        {
            MasterBaseCollection ResultObj = CurManager.GetActiveClaimTypeInLangByEntity(LanguageInUsed, (new Entity(EntityID, EntityID)));

            if (ResultObj != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("Account Code", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Expense Name", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Name in Local Language", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Category", Type.GetType("System.String")));

                for (int x = 0; x < ResultObj.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();

                    GLClaimType CurObj = (GLClaimType)ResultObj[x];

                    ResultRow["Account Code"] = CurObj.GLCode;
                    ResultRow["Expense Name"] = CurObj.ActualName;
                    ResultRow["Name in Local Language"] = CurObj.DisplayName;
                    ResultRow["Category"] = ClaimManager.GetClaimCategoryInString(CurObj.Category);

                    ResultTable.Rows.Add(ResultRow);
                }

            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetActiveExpenseDetailByEntity] : CurManager.GetActiveClaimTypeInLangByEntity('" + LanguageInUsed.InternalID + "', '" + EntityID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion

    #region GetClaimHeadersByDateRange
    public DataTable GetClaimHeadersByDateRange(string CompanyID, DateTime SubmittedDateStart, DateTime SubmittedDateEnd)
    {
        DataTable ResultTable = null;

        using (ClaimManager CurManager = new ClaimManager(this.CurrentModuleSession))
        {
            DataTable ResultObj = CurManager.GetClaimByDateRange(CompanyID, SubmittedDateStart, SubmittedDateEnd.AddDays(1));

            if (ResultObj != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("ClaimantID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeName", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Category", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Purpose", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExpenseType", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Remarks", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SubmittedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExpenseDetail", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("CreditCardDetail", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ProjectID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Status", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ProfitCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountClaimed", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Tax", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Currency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExRate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalAmount", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalCurrency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinalAmount", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FirstApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FirstApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SecondApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SecondApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ThridApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ThirdApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ForthApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ForthApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FifthApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FifthApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Authorizer", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AuthorizedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceAdmin", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceProcessedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceVerifier", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceVerifiedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("OutputDate", Type.GetType("System.String")));

                for (int x = 0; x < ResultObj.Rows.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();
                    string Internal_id = ResultObj.Rows[x]["internal_id"].ToString();
                    //GonzalesClaimHeader CurrentObj = (GonzalesClaimHeader)ResultObj[x];

                    ResultRow["ClaimantID"] = ResultObj.Rows[x]["user_employeeid"].ToString();
                    ResultRow["EmployeeName"] = ResultObj.Rows[x]["claimantname"].ToString();
                    ResultRow["ClaimID"] = ResultObj.Rows[x]["claim_id"].ToString();
                    ResultRow["Category"] = ClaimManager.GetClaimCategoryFromCode(ResultObj.Rows[x]["claim_category"].ToString()).ToString();
                    ResultRow["Purpose"] = ResultObj.Rows[x]["claim_reason"].ToString();
                    ResultRow["ExpenseType"] = "";
                    ResultRow["Remarks"] = ResultObj.Rows[x]["detail_remarks"].ToString();
                    if (ResultObj.Rows[x]["claim_submitted"].ToString().Length > 0)
                    {
                        DateTime SubmittedDate = DateTime.Parse(ResultObj.Rows[x]["claim_submitted"].ToString());
                        ResultRow["SubmittedDate"] = SwissArmy.DateConvert(SubmittedDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                    {
                        ResultRow["SubmittedDate"] = "";
                    }

                    ResultRow["ExpenseDetail"] = ResultObj.Rows[x]["claimtype_desc"].ToString(); ;
                    ResultRow["CreditCardDetail"] = ResultObj.Rows[x]["detail_description"].ToString();
                    ResultRow["ProjectID"] = ResultObj.Rows[x]["detail_projectid"].ToString();
                    ResultRow["Status"] = ClaimManager.GetClaimStatusFromCode(ResultObj.Rows[x]["claim_status"].ToString()).ToString();
                    ResultRow["ProfitCenter"] = ResultObj.Rows[x]["detail_profitcenter"].ToString();
                    ResultRow["AmountClaimed"] = ResultObj.Rows[x]["detail_amt_claimed"].ToString();
                    ResultRow["Tax"] = ResultObj.Rows[x]["detail_tax"].ToString();
                    ResultRow["Currency"] = ResultObj.Rows[x]["detail_ex_rate"].ToString();
                    ResultRow["ExRate"] = ResultObj.Rows[x]["detail_ex"].ToString();
                    ResultRow["LocalAmount"] = ResultObj.Rows[x]["detail_amt_out"].ToString();
                    ResultRow["LocalCurrency"] = ResultObj.Rows[x]["detail_amt_out_cur"].ToString();
                    ResultRow["FinalAmount"] = ResultObj.Rows[x]["detail_amt_final"].ToString();

                    if (ResultObj.Rows[x]["claim_exportedon"].ToString().Length > 0)
                    {
                        DateTime outputDate = DateTime.Parse(ResultObj.Rows[x]["claim_exportedon"].ToString());
                        ResultRow["OutputDate"] = SwissArmy.DateConvert(outputDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/",false);
                    }
                    else
                        ResultRow["OutputDate"] = "";


                    LogsCollection CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Approved");
                    if (CurLog.Count > 0)
                    {
                        if (CurLog.Count == 1)
                        {
                            ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                            ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["SecondApprover"] = "";
                            ResultRow["SecondApprovedDate"] = "";
                            ResultRow["ThridApprover"] = "";
                            ResultRow["ThirdApprovedDate"] = "";
                            ResultRow["ForthApprover"] = "";
                            ResultRow["ForthApprovedDate"] = "";
                            ResultRow["FifthApprover"] = "";
                            ResultRow["FifthApprovedDate"] = "";
                        }
                        else if (CurLog.Count == 2)
                        {
                            ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                            ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                            ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ThridApprover"] = "";
                            ResultRow["ThirdApprovedDate"] = "";
                            ResultRow["ForthApprover"] = "";
                            ResultRow["ForthApprovedDate"] = "";
                            ResultRow["FifthApprover"] = "";
                            ResultRow["FifthApprovedDate"] = "";
                        }
                        else if (CurLog.Count == 3)
                        {
                            ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                            ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                            ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ThridApprover"] = CurLog[2].LoggedBy.DisplayName.ToString();
                            ResultRow["ThirdApprovedDate"] = SwissArmy.DateConvert(CurLog[2].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ForthApprover"] = "";
                            ResultRow["ForthApprovedDate"] = "";
                            ResultRow["FifthApprover"] = "";
                            ResultRow["FifthApprovedDate"] = "";
                        }
                        else if (CurLog.Count == 4)
                        {
                            ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                            ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                            ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ThridApprover"] = CurLog[2].LoggedBy.DisplayName.ToString();
                            ResultRow["ThirdApprovedDate"] = SwissArmy.DateConvert(CurLog[2].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ForthApprover"] = CurLog[3].LoggedBy.DisplayName.ToString();
                            ResultRow["ForthApprovedDate"] = SwissArmy.DateConvert(CurLog[3].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["FifthApprover"] = "";
                            ResultRow["FifthApprovedDate"] = "";
                        }
                        else
                        {
                            ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                            ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                            ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ThridApprover"] = CurLog[2].LoggedBy.DisplayName.ToString();
                            ResultRow["ThirdApprovedDate"] = SwissArmy.DateConvert(CurLog[2].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ForthApprover"] = CurLog[3].LoggedBy.DisplayName.ToString();
                            ResultRow["ForthApprovedDate"] = SwissArmy.DateConvert(CurLog[3].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["FifthApprover"] = CurLog[4].LoggedBy.DisplayName.ToString();
                            ResultRow["FifthApprovedDate"] = SwissArmy.DateConvert(CurLog[4].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                        }
                    }

                    CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Authorized");
                    if (CurLog.Count > 0)
                    {
                        ResultRow["Authorizer"] = CurLog[0].LoggedBy.DisplayName.ToString();
                        ResultRow["AuthorizedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }

                    CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Verified");
                    if (CurLog.Count > 0)
                    {
                        ResultRow["FinanceAdmin"] = CurLog[0].LoggedBy.DisplayName.ToString();
                        ResultRow["FinanceProcessedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }

                    CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Finance Approved");
                    if (CurLog.Count > 0)
                    {
                        ResultRow["FinanceVerifier"] = CurLog[0].LoggedBy.DisplayName.ToString();
                        ResultRow["FinanceVerifiedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    
                    ResultTable.Rows.Add(ResultRow);
                }

            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetClaimantReportsByCompany] : CurManager.GetUsersByCompany('" + CompanyID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion

    #region GetClaimHeadersByDateRangeV1
    public DataTable GetClaimHeadersByDateRangeV1(string CompanyID, DateTime SubmittedDateStart, DateTime SubmittedDateEnd)
    {
        DataTable ResultTable = null;

        using (ClaimManager CurManager = new ClaimManager(this.CurrentModuleSession))
        {
            ClaimHeaders ResultObj = CurManager.GetClaimByDateRangeV1(CompanyID, SubmittedDateStart, SubmittedDateEnd.AddDays(1));

            if (ResultObj != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("InternalID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Category", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Purpose", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SubmittedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalCurrency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountClaimed", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("FinalAmount", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("LessCardsTransaction", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("OwningToFromEmployee", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("ClaimedBy", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimedByID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("CostCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Status", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedBy", Type.GetType("System.String")));


                for (int x = 0; x < ResultObj.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();

                    GonzalesClaimHeader CurrentObj = (GonzalesClaimHeader)ResultObj[x];

                    ResultRow["InternalID"] = CurrentObj.InternalID;
                    ResultRow["ClaimID"] = CurrentObj.ClaimID;
                    ResultRow["Category"] = ClaimManager.GetClaimCategoryInString(CurrentObj.Category);
                    ResultRow["Purpose"] = CurrentObj.Reasons;
                    ResultRow["Status"] = ClaimManager.GetClaimStatusInString(CurrentObj.Status);
                    ResultRow["LocalCurrency"] = CurrentObj.LocalCurrency.InternalID;
                    ResultRow["AmountClaimed"] = CurrentObj.TotalClaimedAmount;
                    ResultRow["FinalAmount"] = CurrentObj.FinalApprovedAmount;
                    ResultRow["LessCardsTransaction"] = CurrentObj.TotalLocalAmountAlreadyPaid;
                    ResultRow["OwningToFromEmployee"] = CurrentObj.TotalLocalActualAmountLeft;
                    ResultRow["ClaimedBy"] = CurrentObj.ClaimedBy.DisplayName + " (" + CurrentObj.ClaimedBy.EmailID + ") ";
                    ResultRow["ClaimedByID"] = CurrentObj.ClaimedBy.InternalID;
                    ResultRow["EmployeeID"] = CurrentObj.ClaimedBy.EmployeeID;
                    ResultRow["CostCenter"] = CurrentObj.ClaimedBy.CostCenter;
                    //Added by Agnes [10 Nov 2009]
                    if (CurrentObj.SubmittedOn.Year > 2000)
                        ResultRow["SubmittedDate"] = SwissArmy.DateConvert(CurrentObj.SubmittedOn, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    else
                        ResultRow["SubmittedDate"] = "";

                    if (CurrentObj.LastUpdatedOn.Year > 2000)
                        ResultRow["LastProcessedDate"] = SwissArmy.DateConvert(CurrentObj.LastUpdatedOn, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    else
                        ResultRow["LastProcessedDate"] = "";

                    ResultRow["LastProcessedBy"] = CurrentObj.LastUpdatedBy.DisplayName;

                    ResultTable.Rows.Add(ResultRow);
                }

            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetClaimantReportsByCompany] : CurManager.GetUsersByCompany('" + CompanyID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion

    //Added by Geok Wiew [26 Aug 2011]
    #region GetClaimHeadersByDateRangeV2
    public DataTable GetClaimHeadersByDateRangeV2(string CompanyID, DateTime SubmittedDateStart, DateTime SubmittedDateEnd)
    {
        DataTable ResultTable = null;

        using (ClaimManager CurManager = new ClaimManager(this.CurrentModuleSession))
        {
            DataTable ResultObj = CurManager.GetClaimByDateRangeV2(CompanyID, SubmittedDateStart, SubmittedDateEnd.AddDays(1));

            if (ResultObj != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("ClaimantID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeName", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Category", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Purpose", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExpenseType", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Remarks", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SubmittedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExpenseDetail", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("CreditCardDetail", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ProjectID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Status", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ProfitCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountClaimed", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Tax", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Currency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExRate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalAmount", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalCurrency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinalAmount", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FirstApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FirstApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SecondApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SecondApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ThirdApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ThirdApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ForthApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ForthApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FifthApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FifthApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SixthApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SixthApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SeventhApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SeventhApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Authorizer", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AuthorizedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceAdmin", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceProcessedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceVerifier", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceVerifiedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("OutputDate", Type.GetType("System.String")));

                for (int x = 0; x < ResultObj.Rows.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();
                    string Internal_id = ResultObj.Rows[x]["internal_id"].ToString();
                    //GonzalesClaimHeader CurrentObj = (GonzalesClaimHeader)ResultObj[x];

                    ResultRow["ClaimantID"] = ResultObj.Rows[x]["user_employeeid"].ToString();
                    ResultRow["EmployeeName"] = ResultObj.Rows[x]["claimantname"].ToString();
                    ResultRow["ClaimID"] = ResultObj.Rows[x]["claim_id"].ToString();
                    ResultRow["Category"] = ClaimManager.GetClaimCategoryFromCode(ResultObj.Rows[x]["claim_category"].ToString()).ToString();
                    ResultRow["Purpose"] = ResultObj.Rows[x]["claim_reason"].ToString();
                    ResultRow["ExpenseType"] = "";
                    ResultRow["Remarks"] = ResultObj.Rows[x]["detail_remarks"].ToString();
                    if (ResultObj.Rows[x]["claim_submitted"].ToString().Length > 0)
                    {
                        DateTime SubmittedDate = DateTime.Parse(ResultObj.Rows[x]["claim_submitted"].ToString());
                        ResultRow["SubmittedDate"] = SwissArmy.DateConvert(SubmittedDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                    {
                        ResultRow["SubmittedDate"] = "";
                    }

                    ResultRow["ExpenseDetail"] = ResultObj.Rows[x]["claimtype_desc"].ToString(); ;
                    ResultRow["CreditCardDetail"] = ResultObj.Rows[x]["detail_description"].ToString();
                    ResultRow["ProjectID"] = ResultObj.Rows[x]["detail_projectid"].ToString();
                    ResultRow["Status"] = ClaimManager.GetClaimStatusFromCode(ResultObj.Rows[x]["claim_status"].ToString()).ToString();
                    ResultRow["ProfitCenter"] = ResultObj.Rows[x]["detail_profitcenter"].ToString();
                    ResultRow["AmountClaimed"] = ResultObj.Rows[x]["detail_amt_claimed"].ToString();
                    ResultRow["Tax"] = ResultObj.Rows[x]["detail_tax"].ToString();
                    ResultRow["Currency"] = ResultObj.Rows[x]["detail_ex_rate"].ToString();
                    ResultRow["ExRate"] = ResultObj.Rows[x]["detail_ex"].ToString();
                    ResultRow["LocalAmount"] = ResultObj.Rows[x]["detail_amt_out"].ToString();
                    ResultRow["LocalCurrency"] = ResultObj.Rows[x]["detail_amt_out_cur"].ToString();
                    ResultRow["FinalAmount"] = ResultObj.Rows[x]["detail_amt_final"].ToString();

                    if (ResultObj.Rows[x]["claim_exportedon"].ToString().Length > 0)
                    {
                        DateTime outputDate = DateTime.Parse(ResultObj.Rows[x]["claim_exportedon"].ToString());
                        ResultRow["OutputDate"] = SwissArmy.DateConvert(outputDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["OutputDate"] = "";

                    // Added by Geok Wiew [26 Aug 2011]
                    ResultRow["FirstApprover"] = ResultObj.Rows[x]["appr1_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr1_date"].ToString().Length > 0)
                    {
                        DateTime Appr1Date = DateTime.Parse(ResultObj.Rows[x]["appr1_date"].ToString());
                        ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(Appr1Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["FirstApprovedDate"] = "";

                    ResultRow["SecondApprover"] = ResultObj.Rows[x]["appr2_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr2_date"].ToString().Length > 0)
                    {
                        DateTime Appr2Date = DateTime.Parse(ResultObj.Rows[x]["appr2_date"].ToString());
                        ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(Appr2Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["SecondApprovedDate"] = "";

                    ResultRow["ThirdApprover"] = ResultObj.Rows[x]["appr3_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr3_date"].ToString().Length > 0)
                    {
                        DateTime Appr3Date = DateTime.Parse(ResultObj.Rows[x]["appr3_date"].ToString());
                        ResultRow["ThirdApprovedDate"] = SwissArmy.DateConvert(Appr3Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["ThirdApprovedDate"] = "";

                    ResultRow["ForthApprover"] = ResultObj.Rows[x]["appr4_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr4_date"].ToString().Length > 0)
                    {
                        DateTime Appr4Date = DateTime.Parse(ResultObj.Rows[x]["appr4_date"].ToString());
                        ResultRow["ForthApprovedDate"] = SwissArmy.DateConvert(Appr4Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["ForthApprovedDate"] = "";

                    ResultRow["FifthApprover"] = ResultObj.Rows[x]["appr5_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr5_date"].ToString().Length > 0)
                    {
                        DateTime Appr5Date = DateTime.Parse(ResultObj.Rows[x]["appr5_date"].ToString());
                        ResultRow["FifthApprovedDate"] = SwissArmy.DateConvert(Appr5Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["FifthApprovedDate"] = "";

                    ResultRow["SixthApprover"] = ResultObj.Rows[x]["appr6_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr6_date"].ToString().Length > 0)
                    {
                        DateTime Appr6Date = DateTime.Parse(ResultObj.Rows[x]["appr6_date"].ToString());
                        ResultRow["SixthApprovedDate"] = SwissArmy.DateConvert(Appr6Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["SixthApprovedDate"] = "";

                    ResultRow["SeventhApprover"] = ResultObj.Rows[x]["appr7_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr7_date"].ToString().Length > 0)
                    {
                        DateTime Appr7Date = DateTime.Parse(ResultObj.Rows[x]["appr7_date"].ToString());
                        ResultRow["SeventhApprovedDate"] = SwissArmy.DateConvert(Appr7Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["SeventhApprovedDate"] = "";

                    ResultRow["Authorizer"] = ResultObj.Rows[x]["authorizer_display_name"].ToString();
                    if (ResultObj.Rows[x]["authorizer_Date"].ToString().Length > 0)
                    {
                        DateTime AutDate = DateTime.Parse(ResultObj.Rows[x]["authorizer_Date"].ToString());
                        ResultRow["AuthorizedDate"] = SwissArmy.DateConvert(AutDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["AuthorizedDate"] = "";


                    ResultRow["FinanceAdmin"] = ResultObj.Rows[x]["authorizer_display_name"].ToString();
                    if (ResultObj.Rows[x]["fa_Date"].ToString().Length > 0)
                    {
                        DateTime FADate = DateTime.Parse(ResultObj.Rows[x]["fa_Date"].ToString());
                        ResultRow["FinanceProcessedDate"] = SwissArmy.DateConvert(FADate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["FinanceProcessedDate"] = "";

                    ResultRow["FinanceVerifier"] = ResultObj.Rows[x]["fv_display_name"].ToString();
                    if (ResultObj.Rows[x]["fv_Date"].ToString().Length > 0)
                    {
                        DateTime FVDate = DateTime.Parse(ResultObj.Rows[x]["fv_Date"].ToString());
                        ResultRow["FinanceVerifiedDate"] = SwissArmy.DateConvert(FVDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["FinanceVerifiedDate"] = "";
                    


                    //LogsCollection CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Approved");
                    //if (CurLog.Count > 0)
                    //{
                    //    if (CurLog.Count == 1)
                    //    {
                    //        ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                    //        ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["SecondApprover"] = "";
                    //        ResultRow["SecondApprovedDate"] = "";
                    //        ResultRow["ThridApprover"] = "";
                    //        ResultRow["ThirdApprovedDate"] = "";
                    //        ResultRow["ForthApprover"] = "";
                    //        ResultRow["ForthApprovedDate"] = "";
                    //        ResultRow["FifthApprover"] = "";
                    //        ResultRow["FifthApprovedDate"] = "";
                    //    }
                    //    else if (CurLog.Count == 2)
                    //    {
                    //        ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                    //        ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                    //        ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["ThridApprover"] = "";
                    //        ResultRow["ThirdApprovedDate"] = "";
                    //        ResultRow["ForthApprover"] = "";
                    //        ResultRow["ForthApprovedDate"] = "";
                    //        ResultRow["FifthApprover"] = "";
                    //        ResultRow["FifthApprovedDate"] = "";
                    //    }
                    //    else if (CurLog.Count == 3)
                    //    {
                    //        ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                    //        ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                    //        ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["ThridApprover"] = CurLog[2].LoggedBy.DisplayName.ToString();
                    //        ResultRow["ThirdApprovedDate"] = SwissArmy.DateConvert(CurLog[2].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["ForthApprover"] = "";
                    //        ResultRow["ForthApprovedDate"] = "";
                    //        ResultRow["FifthApprover"] = "";
                    //        ResultRow["FifthApprovedDate"] = "";
                    //    }
                    //    else if (CurLog.Count == 4)
                    //    {
                    //        ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                    //        ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                    //        ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["ThridApprover"] = CurLog[2].LoggedBy.DisplayName.ToString();
                    //        ResultRow["ThirdApprovedDate"] = SwissArmy.DateConvert(CurLog[2].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["ForthApprover"] = CurLog[3].LoggedBy.DisplayName.ToString();
                    //        ResultRow["ForthApprovedDate"] = SwissArmy.DateConvert(CurLog[3].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["FifthApprover"] = "";
                    //        ResultRow["FifthApprovedDate"] = "";
                    //    }
                    //    else
                    //    {
                    //        ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                    //        ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                    //        ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["ThridApprover"] = CurLog[2].LoggedBy.DisplayName.ToString();
                    //        ResultRow["ThirdApprovedDate"] = SwissArmy.DateConvert(CurLog[2].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["ForthApprover"] = CurLog[3].LoggedBy.DisplayName.ToString();
                    //        ResultRow["ForthApprovedDate"] = SwissArmy.DateConvert(CurLog[3].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //        ResultRow["FifthApprover"] = CurLog[4].LoggedBy.DisplayName.ToString();
                    //        ResultRow["FifthApprovedDate"] = SwissArmy.DateConvert(CurLog[4].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //    }
                    //}

                    //CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Authorized");
                    //if (CurLog.Count > 0)
                    //{
                    //    ResultRow["Authorizer"] = CurLog[0].LoggedBy.DisplayName.ToString();
                    //    ResultRow["AuthorizedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //}

                    //CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Verified");
                    //if (CurLog.Count > 0)
                    //{
                    //    ResultRow["FinanceAdmin"] = CurLog[0].LoggedBy.DisplayName.ToString();
                    //    ResultRow["FinanceProcessedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //}

                    //CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Finance Approved");
                    //if (CurLog.Count > 0)
                    //{
                    //    ResultRow["FinanceVerifier"] = CurLog[0].LoggedBy.DisplayName.ToString();
                    //    ResultRow["FinanceVerifiedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    //}

                    ResultTable.Rows.Add(ResultRow);
                }

            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetClaimantReportsByCompany] : CurManager.GetUsersByCompany('" + CompanyID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion

    #region GetClaimHeadersByDateRangeSummary
    public DataTable GetClaimHeadersByDateRangeSummary(string CompanyID, DateTime SubmittedDateStart, DateTime SubmittedDateEnd)
    {
        DataTable ResultTable = null;

        using (ClaimManager CurManager = new ClaimManager(this.CurrentModuleSession))
        {
            DataTable ResultObj = CurManager.GetClaimByDateRangeSummary(CompanyID, SubmittedDateStart, SubmittedDateEnd.AddDays(1));

            if (ResultObj != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("ClaimantID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeName", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Category", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Purpose", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExpenseType", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Remarks", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SubmittedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExpenseDetail", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("CreditCardDetail", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ProjectID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Status", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ProfitCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountClaimed", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Tax", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Currency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExRate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalAmount", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalCurrency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinalAmount", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FirstApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FirstApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SecondApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SecondApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ThridApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ThirdApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ForthApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ForthApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FifthApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FifthApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Authorizer", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AuthorizedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceAdmin", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceProcessedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceVerifier", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceVerifiedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("OutputDate", Type.GetType("System.String")));

                for (int x = 0; x < ResultObj.Rows.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();
                    string Internal_id = ResultObj.Rows[x]["internal_id"].ToString();
                    //GonzalesClaimHeader CurrentObj = (GonzalesClaimHeader)ResultObj[x];

                    ResultRow["ClaimantID"] = ResultObj.Rows[x]["user_employeeid"].ToString();
                    ResultRow["EmployeeName"] = ResultObj.Rows[x]["claimantname"].ToString();
                    ResultRow["ClaimID"] = ResultObj.Rows[x]["claim_id"].ToString();
                    ResultRow["Category"] = ClaimManager.GetClaimCategoryFromCode(ResultObj.Rows[x]["claim_category"].ToString()).ToString();
                    ResultRow["Purpose"] = ResultObj.Rows[x]["claim_reason"].ToString();
                    ResultRow["ExpenseType"] = "";
                    ResultRow["Remarks"] = ResultObj.Rows[x]["detail_remarks"].ToString();
                    if (ResultObj.Rows[x]["claim_submitted"].ToString().Length > 0)
                    {
                        DateTime SubmittedDate = DateTime.Parse(ResultObj.Rows[x]["claim_submitted"].ToString());
                        ResultRow["SubmittedDate"] = SwissArmy.DateConvert(SubmittedDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                    {
                        ResultRow["SubmittedDate"] = "";
                    }

                    ResultRow["ExpenseDetail"] = ResultObj.Rows[x]["claimtype_desc"].ToString(); ;
                    ResultRow["CreditCardDetail"] = ResultObj.Rows[x]["detail_description"].ToString();
                    ResultRow["ProjectID"] = ResultObj.Rows[x]["detail_projectid"].ToString();
                    ResultRow["Status"] = ClaimManager.GetClaimStatusFromCode(ResultObj.Rows[x]["claim_status"].ToString()).ToString();
                    ResultRow["ProfitCenter"] = ResultObj.Rows[x]["detail_profitcenter"].ToString();
                    ResultRow["AmountClaimed"] = ResultObj.Rows[x]["detail_amt_claimed"].ToString();
                    ResultRow["Tax"] = ResultObj.Rows[x]["detail_tax"].ToString();
                    ResultRow["Currency"] = ResultObj.Rows[x]["detail_ex_rate"].ToString();
                    ResultRow["ExRate"] = ResultObj.Rows[x]["detail_ex"].ToString();
                    ResultRow["LocalAmount"] = ResultObj.Rows[x]["detail_amt_out"].ToString();
                    ResultRow["LocalCurrency"] = ResultObj.Rows[x]["detail_amt_out_cur"].ToString();
                    ResultRow["FinalAmount"] = ResultObj.Rows[x]["detail_amt_final"].ToString();

                    if (ResultObj.Rows[x]["claim_exportedon"].ToString().Length > 0)
                    {
                        DateTime outputDate = DateTime.Parse(ResultObj.Rows[x]["claim_exportedon"].ToString());
                        ResultRow["OutputDate"] = SwissArmy.DateConvert(outputDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["OutputDate"] = "";

                    LogsCollection CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Approved");
                    if (CurLog.Count > 0)
                    {
                        if (CurLog.Count == 1)
                        {
                            ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                            ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["SecondApprover"] = "";
                            ResultRow["SecondApprovedDate"] = "";
                            ResultRow["ThridApprover"] = "";
                            ResultRow["ThirdApprovedDate"] = "";
                            ResultRow["ForthApprover"] = "";
                            ResultRow["ForthApprovedDate"] = "";
                            ResultRow["FifthApprover"] = "";
                            ResultRow["FifthApprovedDate"] = "";
                        }
                        else if (CurLog.Count == 2)
                        {
                            ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                            ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                            ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ThridApprover"] = "";
                            ResultRow["ThirdApprovedDate"] = "";
                            ResultRow["ForthApprover"] = "";
                            ResultRow["ForthApprovedDate"] = "";
                            ResultRow["FifthApprover"] = "";
                            ResultRow["FifthApprovedDate"] = "";
                        }
                        else if (CurLog.Count == 3)
                        {
                            ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                            ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                            ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ThridApprover"] = CurLog[2].LoggedBy.DisplayName.ToString();
                            ResultRow["ThirdApprovedDate"] = SwissArmy.DateConvert(CurLog[2].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ForthApprover"] = "";
                            ResultRow["ForthApprovedDate"] = "";
                            ResultRow["FifthApprover"] = "";
                            ResultRow["FifthApprovedDate"] = "";
                        }
                        else if (CurLog.Count == 4)
                        {
                            ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                            ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                            ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ThridApprover"] = CurLog[2].LoggedBy.DisplayName.ToString();
                            ResultRow["ThirdApprovedDate"] = SwissArmy.DateConvert(CurLog[2].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ForthApprover"] = CurLog[3].LoggedBy.DisplayName.ToString();
                            ResultRow["ForthApprovedDate"] = SwissArmy.DateConvert(CurLog[3].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["FifthApprover"] = "";
                            ResultRow["FifthApprovedDate"] = "";
                        }
                        else
                        {
                            ResultRow["FirstApprover"] = CurLog[0].LoggedBy.DisplayName.ToString();
                            ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["SecondApprover"] = CurLog[1].LoggedBy.DisplayName.ToString();
                            ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(CurLog[1].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ThridApprover"] = CurLog[2].LoggedBy.DisplayName.ToString();
                            ResultRow["ThirdApprovedDate"] = SwissArmy.DateConvert(CurLog[2].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["ForthApprover"] = CurLog[3].LoggedBy.DisplayName.ToString();
                            ResultRow["ForthApprovedDate"] = SwissArmy.DateConvert(CurLog[3].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                            ResultRow["FifthApprover"] = CurLog[4].LoggedBy.DisplayName.ToString();
                            ResultRow["FifthApprovedDate"] = SwissArmy.DateConvert(CurLog[4].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                        }
                    }

                    CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Authorized");
                    if (CurLog.Count > 0)
                    {
                        ResultRow["Authorizer"] = CurLog[0].LoggedBy.DisplayName.ToString();
                        ResultRow["AuthorizedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }

                    CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Verified");
                    if (CurLog.Count > 0)
                    {
                        ResultRow["FinanceAdmin"] = CurLog[0].LoggedBy.DisplayName.ToString();
                        ResultRow["FinanceProcessedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }

                    CurLog = CurrentLogManager.GetActionLogByClaimIDClaimAction(Internal_id, "Claim Finance Approved");
                    if (CurLog.Count > 0)
                    {
                        ResultRow["FinanceVerifier"] = CurLog[0].LoggedBy.DisplayName.ToString();
                        ResultRow["FinanceVerifiedDate"] = SwissArmy.DateConvert(CurLog[0].LogDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }

                    ResultTable.Rows.Add(ResultRow);
                }

            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetClaimantReportsByCompany] : CurManager.GetUsersByCompany('" + CompanyID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
      #endregion

    //Added by Geok Wiew [26 Aug 2011]
    #region GetClaimHeadersByDateRangeSummaryV2
    public DataTable GetClaimHeadersByDateRangeSummaryV2(string CompanyID, DateTime SubmittedDateStart, DateTime SubmittedDateEnd)
    {
        DataTable ResultTable = null;

        using (ClaimManager CurManager = new ClaimManager(this.CurrentModuleSession))
        {
            DataTable ResultObj = CurManager.GetClaimByDateRangeSummaryV2(CompanyID, SubmittedDateStart, SubmittedDateEnd.AddDays(1));

            if (ResultObj != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("ClaimantID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeName", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Category", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Purpose", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExpenseType", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Remarks", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SubmittedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExpenseDetail", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("CreditCardDetail", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ProjectID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Status", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ProfitCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountClaimed", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Tax", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Currency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExRate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalAmount", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalCurrency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinalAmount", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FirstApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FirstApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SecondApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SecondApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ThirdApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ThirdApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ForthApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ForthApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FifthApprover", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FifthApprovedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Authorizer", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AuthorizedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceAdmin", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceProcessedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceVerifier", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("FinanceVerifiedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("OutputDate", Type.GetType("System.String")));

                for (int x = 0; x < ResultObj.Rows.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();
                    string Internal_id = ResultObj.Rows[x]["internal_id"].ToString();

                    ResultRow["ClaimantID"] = ResultObj.Rows[x]["user_employeeid"].ToString();
                    ResultRow["EmployeeName"] = ResultObj.Rows[x]["claimantname"].ToString();
                    ResultRow["ClaimID"] = ResultObj.Rows[x]["claim_id"].ToString();
                    ResultRow["Category"] = ClaimManager.GetClaimCategoryFromCode(ResultObj.Rows[x]["claim_category"].ToString()).ToString();
                    ResultRow["Purpose"] = ResultObj.Rows[x]["claim_reason"].ToString();
                    ResultRow["ExpenseType"] = "";
                    ResultRow["Remarks"] = ResultObj.Rows[x]["detail_remarks"].ToString();
                    if (ResultObj.Rows[x]["claim_submitted"].ToString().Length > 0)
                    {
                        DateTime SubmittedDate = DateTime.Parse(ResultObj.Rows[x]["claim_submitted"].ToString());
                        ResultRow["SubmittedDate"] = SwissArmy.DateConvert(SubmittedDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                    {
                        ResultRow["SubmittedDate"] = "";
                    }

                    ResultRow["ExpenseDetail"] = ResultObj.Rows[x]["claimtype_desc"].ToString(); ;
                    ResultRow["CreditCardDetail"] = ResultObj.Rows[x]["detail_description"].ToString();
                    ResultRow["ProjectID"] = ResultObj.Rows[x]["detail_projectid"].ToString();
                    ResultRow["Status"] = ClaimManager.GetClaimStatusFromCode(ResultObj.Rows[x]["claim_status"].ToString()).ToString();
                    ResultRow["ProfitCenter"] = ResultObj.Rows[x]["detail_profitcenter"].ToString();
                    ResultRow["AmountClaimed"] = ResultObj.Rows[x]["detail_amt_claimed"].ToString();
                    ResultRow["Tax"] = ResultObj.Rows[x]["detail_tax"].ToString();
                    ResultRow["Currency"] = ResultObj.Rows[x]["detail_ex_rate"].ToString();
                    ResultRow["ExRate"] = ResultObj.Rows[x]["detail_ex"].ToString();
                    ResultRow["LocalAmount"] = ResultObj.Rows[x]["detail_amt_out"].ToString();
                    ResultRow["LocalCurrency"] = ResultObj.Rows[x]["detail_amt_out_cur"].ToString();
                    ResultRow["FinalAmount"] = ResultObj.Rows[x]["detail_amt_final"].ToString();

                    if (ResultObj.Rows[x]["claim_exportedon"].ToString().Length > 0)
                    {
                        DateTime outputDate = DateTime.Parse(ResultObj.Rows[x]["claim_exportedon"].ToString());
                        ResultRow["OutputDate"] = SwissArmy.DateConvert(outputDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["OutputDate"] = "";

                    // Added by Geok Wiew [26 Aug 2011]
                    ResultRow["FirstApprover"] = ResultObj.Rows[x]["appr1_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr1_date"].ToString().Length > 0)
                    {
                        DateTime Appr1Date = DateTime.Parse(ResultObj.Rows[x]["appr1_date"].ToString());
                        ResultRow["FirstApprovedDate"] = SwissArmy.DateConvert(Appr1Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["FirstApprovedDate"] = "";

                    ResultRow["SecondApprover"] = ResultObj.Rows[x]["appr2_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr2_date"].ToString().Length > 0)
                    {
                        DateTime Appr2Date = DateTime.Parse(ResultObj.Rows[x]["appr2_date"].ToString());
                        ResultRow["SecondApprovedDate"] = SwissArmy.DateConvert(Appr2Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["SecondApprovedDate"] = "";

                    ResultRow["ThirdApprover"] = ResultObj.Rows[x]["appr3_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr3_date"].ToString().Length > 0)
                    {
                        DateTime Appr3Date = DateTime.Parse(ResultObj.Rows[x]["appr3_date"].ToString());
                        ResultRow["ThirdApprovedDate"] = SwissArmy.DateConvert(Appr3Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["ThirdApprovedDate"] = "";

                    ResultRow["ForthApprover"] = ResultObj.Rows[x]["appr4_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr4_date"].ToString().Length > 0)
                    {
                        DateTime Appr4Date = DateTime.Parse(ResultObj.Rows[x]["appr4_date"].ToString());
                        ResultRow["ForthApprovedDate"] = SwissArmy.DateConvert(Appr4Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["ForthApprovedDate"] = "";

                    ResultRow["FifthApprover"] = ResultObj.Rows[x]["appr5_display_name"].ToString();
                    if (ResultObj.Rows[x]["appr5_date"].ToString().Length > 0)
                    {
                        DateTime Appr5Date = DateTime.Parse(ResultObj.Rows[x]["appr5_date"].ToString());
                        ResultRow["FifthApprovedDate"] = SwissArmy.DateConvert(Appr5Date, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["FifthApprovedDate"] = "";

                    ResultRow["Authorizer"] = ResultObj.Rows[x]["authorizer_display_name"].ToString();
                    if (ResultObj.Rows[x]["authorizer_Date"].ToString().Length > 0)
                    {
                        DateTime AutDate = DateTime.Parse(ResultObj.Rows[x]["authorizer_Date"].ToString());
                        ResultRow["AuthorizedDate"] = SwissArmy.DateConvert(AutDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["AuthorizedDate"] = "";


                    ResultRow["FinanceAdmin"] = ResultObj.Rows[x]["authorizer_display_name"].ToString();
                    if (ResultObj.Rows[x]["fa_Date"].ToString().Length > 0)
                    {
                        DateTime FADate = DateTime.Parse(ResultObj.Rows[x]["fa_Date"].ToString());
                        ResultRow["FinanceProcessedDate"] = SwissArmy.DateConvert(FADate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["FinanceProcessedDate"] = "";

                    ResultRow["FinanceVerifier"] = ResultObj.Rows[x]["fv_display_name"].ToString();
                    if (ResultObj.Rows[x]["fv_Date"].ToString().Length > 0)
                    {
                        DateTime FVDate = DateTime.Parse(ResultObj.Rows[x]["fv_Date"].ToString());
                        ResultRow["FinanceVerifiedDate"] = SwissArmy.DateConvert(FVDate, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/", false);
                    }
                    else
                        ResultRow["FinanceVerifiedDate"] = "";

                    ResultTable.Rows.Add(ResultRow);
                }

            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetClaimantReportsByCompany] : CurManager.GetUsersByCompany('" + CompanyID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion


    #region GetAccrualReport
    public DataTable GetAccrualReport(string LanguageID, string CompanyID, DateTime DateFrom, DateTime DateTo, string ClaimStatus)
    {
        DataTable ResultTable = null;

        using (ReportManager CurManager = new ReportManager(this.CurrentModuleSession))
        {
            DataTable CurResultTable = CurManager.AccrualReport(LanguageID, CompanyID, DateFrom, DateTo, ClaimStatus);
            if (CurResultTable != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("RowNo", Type.GetType("System.Int32")));
                ResultTable.Columns.Add(new DataColumn("EmployeeName", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ProjectID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Description", Type.GetType("System.String")));                                

                ResultTable.Columns.Add(new DataColumn("ProfitCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExpenseDetailID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountInUSD", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountInLocal", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimSubmittedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimStatus", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AgingDays", Type.GetType("System.String")));


                //ResultTable.Columns.Add(new DataColumn("InternalID", Type.GetType("System.String")));               
                //ResultTable.Columns.Add(new DataColumn("ExRate", Type.GetType("System.Decimal")));

                //ResultTable.Columns.Add(new DataColumn("Reasons", Type.GetType("System.String")));

                int x = 1;

                foreach (DataRow ResultRow in CurResultTable.Rows)
                {
                    DataRow NewResultRow = ResultTable.NewRow();

                    NewResultRow["RowNo"] = x++;
                    NewResultRow["ProfitCenter"] = ResultRow[5];
                    NewResultRow["ExpenseDetailID"] = ResultRow[3];

                    decimal AmountInUSD = Math.Round(decimal.Parse(ResultRow[9].ToString()), 2);
                    NewResultRow["AmountInUSD"] = AmountInUSD.ToString(GonzalesGeneralVariables.CurrencyFormat);

                    NewResultRow["EmployeeName"] = ResultRow[7];
                    //NewResultRow["InternalID"] = ResultRow[0];
                    NewResultRow["ClaimID"] = ResultRow[2];

                    decimal AmountLocal = decimal.Parse(ResultRow[8].ToString());
                    NewResultRow["AmountInLocal"] = AmountLocal.ToString(GonzalesGeneralVariables.CurrencyFormat);
                    //NewResultRow["ExRate"] = ResultRow[10];
                    NewResultRow["ProjectID"] = ResultRow[11];
                    //NewResultRow["Reasons"] = ResultRow[12];

                    DateTime dtSubmit = Convert.ToDateTime(ResultRow[14]);
                    if (dtSubmit.Year > 2000)
                    {
                        NewResultRow["ClaimSubmittedDate"] = SwissArmy.DateConvert(dtSubmit, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    }
                    else
                        NewResultRow["ClaimSubmittedDate"] = "";

                    NewResultRow["ClaimStatus"] = ClaimManager.GetClaimStatusInString(ClaimManager.GetClaimStatusFromCode(ResultRow[1].ToString()));
                    if (NewResultRow["ClaimStatus"].ToString().CompareTo("") == 0)
                        NewResultRow["ClaimStatus"] = "Holding Area";

                    DateTime dtUpdated = Convert.ToDateTime(ResultRow[13]);
                    if (dtUpdated.Year > 2000)
                    {
                        NewResultRow["LastProcessedDate"] = SwissArmy.DateConvert(dtUpdated, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    }
                    else
                        NewResultRow["LastProcessedDate"] = "";

                    if (dtUpdated.Year > 2000)
                    {
                        string today = DateTime.Now.ToString("dd/MM/yyyy");
                        string dtUpdate = dtUpdated.ToString("dd/MM/yyyy");

                        System.Globalization.DateTimeFormatInfo formatInfo = new System.Globalization.DateTimeFormatInfo();
                        formatInfo.ShortDatePattern = "dd/MM/yyyy";

                        DateTime d1 = DateTime.Parse(today, formatInfo);
                        DateTime d2 = DateTime.Parse(dtUpdate, formatInfo);

                        TimeSpan tp = d1.Subtract(d2);
                        string Aging = tp.Days.ToString();
                        NewResultRow["AgingDays"] = Aging;
                    }
                    else
                        NewResultRow["AgingDays"] = "";

                    NewResultRow["EmployeeID"] = ResultRow[6];

                    NewResultRow["Description"] = ResultRow[4];                                        

                    ResultTable.Rows.Add(NewResultRow);
                }
            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetAccrualReport] : CurManager.AccrualReport('" + LanguageID + "', '" + CompanyID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion

    #region GetAccrualSummaryReport
    public DataTable GetAccrualSummaryReport(string LanguageID, string CompanyID, DateTime DateFrom, DateTime DateTo, string ClaimStatus)
    {
        DataTable ResultTable = null;

        using (ReportManager CurManager = new ReportManager(this.CurrentModuleSession))
        {
            DataTable CurResultTable = CurManager.AccrualReportSummary(LanguageID, CompanyID, DateFrom, DateTo, ClaimStatus);
            if (CurResultTable != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("RowNo", Type.GetType("System.Int32")));
                ResultTable.Columns.Add(new DataColumn("EmployeeName", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ProjectID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Description", Type.GetType("System.String")));

                ResultTable.Columns.Add(new DataColumn("ProfitCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ExpenseDetailID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountInUSD", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountInLocal", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimSubmittedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimStatus", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AgingDays", Type.GetType("System.String")));


                //ResultTable.Columns.Add(new DataColumn("InternalID", Type.GetType("System.String")));               
                //ResultTable.Columns.Add(new DataColumn("ExRate", Type.GetType("System.Decimal")));

                //ResultTable.Columns.Add(new DataColumn("Reasons", Type.GetType("System.String")));

                int x = 1;

                foreach (DataRow ResultRow in CurResultTable.Rows)
                {
                    DataRow NewResultRow = ResultTable.NewRow();

                    NewResultRow["RowNo"] = x++;
                    NewResultRow["ProfitCenter"] = ResultRow[5];
                    NewResultRow["ExpenseDetailID"] = "";

                    decimal AmountInUSD = Math.Round(decimal.Parse(ResultRow[9].ToString()), 2);
                    NewResultRow["AmountInUSD"] = AmountInUSD.ToString(GonzalesGeneralVariables.CurrencyFormat);

                    NewResultRow["EmployeeName"] = ResultRow[7];
                    //NewResultRow["InternalID"] = ResultRow[0];
                    NewResultRow["ClaimID"] = ResultRow[2];

                    decimal AmountLocal = decimal.Parse(ResultRow[8].ToString());
                    NewResultRow["AmountInLocal"] = AmountLocal.ToString(GonzalesGeneralVariables.CurrencyFormat);
                    //NewResultRow["ExRate"] = ResultRow[10];
                    NewResultRow["ProjectID"] = ResultRow[11];
                    //NewResultRow["Reasons"] = ResultRow[12];

                    DateTime dtSubmit = Convert.ToDateTime(ResultRow[14]);
                    if (dtSubmit.Year > 2000)
                    {
                        NewResultRow["ClaimSubmittedDate"] = SwissArmy.DateConvert(dtSubmit, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    }
                    else
                        NewResultRow["ClaimSubmittedDate"] = "";

                    NewResultRow["ClaimStatus"] = ClaimManager.GetClaimStatusInString(ClaimManager.GetClaimStatusFromCode(ResultRow[1].ToString()));
                    if (NewResultRow["ClaimStatus"].ToString().CompareTo("") == 0)
                        NewResultRow["ClaimStatus"] = "Holding Area";

                    DateTime dtUpdated = Convert.ToDateTime(ResultRow[13]);
                    if (dtUpdated.Year > 2000)
                    {
                        NewResultRow["LastProcessedDate"] = SwissArmy.DateConvert(dtUpdated, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    }
                    else
                        NewResultRow["LastProcessedDate"] = "";

                    if (dtUpdated.Year > 2000)
                    {
                        string today = DateTime.Now.ToString("dd/MM/yyyy");
                        string dtUpdate = dtUpdated.ToString("dd/MM/yyyy");

                        System.Globalization.DateTimeFormatInfo formatInfo = new System.Globalization.DateTimeFormatInfo();
                        formatInfo.ShortDatePattern = "dd/MM/yyyy";

                        DateTime d1 = DateTime.Parse(today, formatInfo);
                        DateTime d2 = DateTime.Parse(dtUpdate, formatInfo);

                        TimeSpan tp = d1.Subtract(d2);
                        string Aging = tp.Days.ToString();
                        NewResultRow["AgingDays"] = Aging;
                    }
                    else
                        NewResultRow["AgingDays"] = "";

                    NewResultRow["EmployeeID"] = ResultRow[6];

                    NewResultRow["Description"] = ResultRow[4];

                    ResultTable.Rows.Add(NewResultRow);
                }
            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetAccrualReport] : CurManager.AccrualReport('" + LanguageID + "', '" + CompanyID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion

    #region GetCreditCardOverview

    public DataTable GetCreditCardOverview(string CompanyID)
    {
        DataTable ResultTable = null;

        using (ReportManager CurManager = new ReportManager(this.CurrentModuleSession))
        {
            ResultTable = CurManager.CreditCardOverviewReport(CompanyID);
        }

        return ResultTable;
    }

    #endregion

    #region GenerateCSV
    public static bool GenerateCSV(DataTable ResultTable, string path, ref string ResponseMessage)
    {
        bool smooth = true;

        StringBuilder ReportBuilder = new StringBuilder();
        StringBuilder DataRowBuilder = new StringBuilder();
        
        try
        {
            if (ResultTable != null)
            {
                // header
                foreach (DataColumn ResultColumn in ResultTable.Columns)
                {
                    DataRowBuilder.Append(ResultColumn.ColumnName + ",");
                }

                ReportBuilder.AppendLine(DataRowBuilder.ToString().Substring(0, (DataRowBuilder.ToString().Length-1)));
                
                // data
                foreach (DataRow ResultRow in ResultTable.Rows)
                {
                    DataRowBuilder = new StringBuilder();

                    foreach (DataColumn ResultColumn in ResultTable.Columns)
                    {
                        if (ResultRow[ResultColumn.ColumnName].ToString().IndexOf(",") >= 0)
                        {
                            DataRowBuilder.Append("\"" + ResultRow[ResultColumn.ColumnName].ToString() + "\"" + ",");
                        }
                        else
                        {
                            DataRowBuilder.Append(ResultRow[ResultColumn.ColumnName].ToString() + ",");
                        }
                    }

                    ReportBuilder.AppendLine(DataRowBuilder.ToString().Substring(0, (DataRowBuilder.ToString().Length - 1)));
                }

                // create the file now
                SwissArmy.FileCreate(path, ReportBuilder.ToString());
            }
        }
        catch (Exception ex)
        {
            smooth = false;
            ResponseMessage = "[ReportsGenerator.GenerateCSV] : Exception : " + ex.Message;
        }

        return smooth;
    }
    #endregion

    //Added by mei chze on 18072012
    #region GetClaimHeadersByID
    public DataTable GetClaimHeadersByID(string ClaimID, string entity, string company, string claimant )
    {
        DataTable ResultTable = null;

        using (ClaimManager CurManager = new ClaimManager(this.CurrentModuleSession))
        {
            ClaimHeaders ResultObj = CurManager.GetClaimByID(ClaimID, entity, company, claimant);

            if (ResultObj != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("InternalID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Category", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Purpose", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SubmittedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalCurrency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountClaimed", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("FinalAmount", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("LessCardsTransaction", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("OwningToFromEmployee", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("ClaimedBy", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimedByID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("CostCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Status", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedBy", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("companyname", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("entityname", Type.GetType("System.String")));

                for (int x = 0; x < ResultObj.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();

                    GonzalesClaimHeader CurrentObj = (GonzalesClaimHeader)ResultObj[x];

                    ResultRow["InternalID"] = CurrentObj.InternalID;
                    ResultRow["ClaimID"] = CurrentObj.ClaimID;
                    ResultRow["Category"] = ClaimManager.GetClaimCategoryInString(CurrentObj.Category);
                    ResultRow["Purpose"] = CurrentObj.Reasons;
                    ResultRow["Status"] = ClaimManager.GetClaimStatusInString(CurrentObj.Status);
                    ResultRow["LocalCurrency"] = CurrentObj.LocalCurrency.InternalID;
                    ResultRow["AmountClaimed"] = CurrentObj.TotalClaimedAmount;
                    ResultRow["FinalAmount"] = CurrentObj.FinalApprovedAmount;
                    ResultRow["LessCardsTransaction"] = CurrentObj.TotalLocalAmountAlreadyPaid;
                    ResultRow["OwningToFromEmployee"] = CurrentObj.TotalLocalActualAmountLeft;
                    ResultRow["ClaimedBy"] = CurrentObj.ClaimedBy.DisplayName + " (" + CurrentObj.ClaimedBy.EmailID + ") ";
                    ResultRow["ClaimedByID"] = CurrentObj.ClaimedBy.InternalID;
                    ResultRow["EmployeeID"] = CurrentObj.ClaimedBy.EmployeeID;
                    ResultRow["CostCenter"] = CurrentObj.ClaimedBy.CostCenter;
                    using (UserManager  curCompanyManager = new UserManager (this.CurrentModuleSession))
                    {
                        SystemUser comp = curCompanyManager.GetUserByInternalID(CurrentObj.InternalID);
                        if (comp != null)
                        {
                            ResultRow["companyname"] = comp.FromCompany.CompanyName;
                            ResultRow["entityname"] = comp.FromCompany.Entity.DisplayName;
                        }
                    }
                  

                    //Added by Agnes [10 Nov 2009]
                    if (CurrentObj.SubmittedOn.Year > 2000)
                        ResultRow["SubmittedDate"] = SwissArmy.DateConvert(CurrentObj.SubmittedOn, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    else
                        ResultRow["SubmittedDate"] = "";

                    if (CurrentObj.LastUpdatedOn.Year > 2000)
                        ResultRow["LastProcessedDate"] = SwissArmy.DateConvert(CurrentObj.LastUpdatedOn, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    else
                        ResultRow["LastProcessedDate"] = "";

                    ResultRow["LastProcessedBy"] = CurrentObj.LastUpdatedBy.DisplayName;

                    ResultTable.Rows.Add(ResultRow);
                }

            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetClaimantReportsByCompany] : CurManager.GetClaimHeadersByID('" + ClaimID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion

    #region GetClaimHeadersByInternalID
    public DataTable GetClaimHeadersByInternalID(string ClaimID)
    {
        DataTable ResultTable = null;

        using (ClaimManager CurManager = new ClaimManager(this.CurrentModuleSession))
        {
            ClaimHeaders ResultObj = CurManager.GetClaimByInternalID1(ClaimID);

            if (ResultObj != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("InternalID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Category", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Purpose", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SubmittedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalCurrency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountClaimed", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("FinalAmount", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("LessCardsTransaction", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("OwningToFromEmployee", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("ClaimedBy", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimedByID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("CostCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Status", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedBy", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("companyname", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("entityname", Type.GetType("System.String")));

                for (int x = 0; x < ResultObj.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();

                    GonzalesClaimHeader CurrentObj = (GonzalesClaimHeader)ResultObj[x];

                    ResultRow["InternalID"] = CurrentObj.InternalID;
                    ResultRow["ClaimID"] = CurrentObj.ClaimID;
                    ResultRow["Category"] = ClaimManager.GetClaimCategoryInString(CurrentObj.Category);
                    ResultRow["Purpose"] = CurrentObj.Reasons;
                    ResultRow["Status"] = ClaimManager.GetClaimStatusInString(CurrentObj.Status);
                    ResultRow["LocalCurrency"] = CurrentObj.LocalCurrency.InternalID;
                    ResultRow["AmountClaimed"] = CurrentObj.TotalClaimedAmount;
                    ResultRow["FinalAmount"] = CurrentObj.FinalApprovedAmount;
                    ResultRow["LessCardsTransaction"] = CurrentObj.TotalLocalAmountAlreadyPaid;
                    ResultRow["OwningToFromEmployee"] = CurrentObj.TotalLocalActualAmountLeft;
                    ResultRow["ClaimedBy"] = CurrentObj.ClaimedBy.DisplayName + " (" + CurrentObj.ClaimedBy.EmailID + ") ";
                    ResultRow["ClaimedByID"] = CurrentObj.ClaimedBy.InternalID;
                    ResultRow["EmployeeID"] = CurrentObj.ClaimedBy.EmployeeID;
                    ResultRow["CostCenter"] = CurrentObj.ClaimedBy.CostCenter;
                    using (UserManager curCompanyManager = new UserManager(this.CurrentModuleSession))
                    {
                        SystemUser comp = curCompanyManager.GetUserByInternalID(CurrentObj.InternalID);
                        if (comp != null)
                        {
                            ResultRow["companyname"] = comp.FromCompany.CompanyName;
                            ResultRow["entityname"] = comp.FromCompany.Entity.DisplayName;
                        }
                    }


                    //Added by Agnes [10 Nov 2009]
                    if (CurrentObj.SubmittedOn.Year > 2000)
                        ResultRow["SubmittedDate"] = SwissArmy.DateConvert(CurrentObj.SubmittedOn, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    else
                        ResultRow["SubmittedDate"] = "";

                    if (CurrentObj.LastUpdatedOn.Year > 2000)
                        ResultRow["LastProcessedDate"] = SwissArmy.DateConvert(CurrentObj.LastUpdatedOn, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    else
                        ResultRow["LastProcessedDate"] = "";

                    ResultRow["LastProcessedBy"] = CurrentObj.LastUpdatedBy.DisplayName;

                    ResultTable.Rows.Add(ResultRow);
                }

            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetClaimantReportsByCompany] : CurManager.GetClaimHeadersByID('" + ClaimID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion


    #region GetClaimHeadersByCompanyID
    public DataTable GetClaimHeadersByCompanyID(string CompanyID)
    {
        DataTable ResultTable = null;

        using (ClaimManager CurManager = new ClaimManager(this.CurrentModuleSession))
        {
            ClaimHeaders ResultObj = CurManager.GetClaimByCompanyID(CompanyID);

            if (ResultObj != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("InternalID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Category", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Purpose", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SubmittedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalCurrency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountClaimed", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("FinalAmount", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("LessCardsTransaction", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("OwningToFromEmployee", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("ClaimedBy", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimedByID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("CostCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Status", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedBy", Type.GetType("System.String")));


                for (int x = 0; x < ResultObj.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();

                    GonzalesClaimHeader CurrentObj = (GonzalesClaimHeader)ResultObj[x];

                    ResultRow["InternalID"] = CurrentObj.InternalID;
                    ResultRow["ClaimID"] = CurrentObj.ClaimID;
                    ResultRow["Category"] = ClaimManager.GetClaimCategoryInString(CurrentObj.Category);
                    ResultRow["Purpose"] = CurrentObj.Reasons;
                    ResultRow["Status"] = ClaimManager.GetClaimStatusInString(CurrentObj.Status);
                    ResultRow["LocalCurrency"] = CurrentObj.LocalCurrency.InternalID;
                    ResultRow["AmountClaimed"] = CurrentObj.TotalClaimedAmount;
                    ResultRow["FinalAmount"] = CurrentObj.FinalApprovedAmount;
                    ResultRow["LessCardsTransaction"] = CurrentObj.TotalLocalAmountAlreadyPaid;
                    ResultRow["OwningToFromEmployee"] = CurrentObj.TotalLocalActualAmountLeft;
                    ResultRow["ClaimedBy"] = CurrentObj.ClaimedBy.DisplayName + " (" + CurrentObj.ClaimedBy.EmailID + ") ";
                    ResultRow["ClaimedByID"] = CurrentObj.ClaimedBy.InternalID;
                    ResultRow["EmployeeID"] = CurrentObj.ClaimedBy.EmployeeID;
                    ResultRow["CostCenter"] = CurrentObj.ClaimedBy.CostCenter;
                    //Added by Agnes [10 Nov 2009]
                    if (CurrentObj.SubmittedOn.Year > 2000)
                        ResultRow["SubmittedDate"] = SwissArmy.DateConvert(CurrentObj.SubmittedOn, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    else
                        ResultRow["SubmittedDate"] = "";

                    if (CurrentObj.LastUpdatedOn.Year > 2000)
                        ResultRow["LastProcessedDate"] = SwissArmy.DateConvert(CurrentObj.LastUpdatedOn, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    else
                        ResultRow["LastProcessedDate"] = "";

                    ResultRow["LastProcessedBy"] = CurrentObj.LastUpdatedBy.DisplayName;

                    ResultTable.Rows.Add(ResultRow);
                }

            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetClaimantReportsByCompany] : CurManager.GetUsersByCompany('" + CompanyID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion

    #region GetClaimHeadersByCompanyID
    public DataTable GetClaimHeadersByCompanyID2(string claim_id,string entity,string CompanyID, string claimant)
    {
        DataTable ResultTable = null;

        using (ClaimManager CurManager = new ClaimManager(this.CurrentModuleSession))
        {
            ClaimHeaders ResultObj = CurManager.GetClaimByID(claim_id,entity,CompanyID,claimant );

            if (ResultObj != null)
            {
                ResultTable = new DataTable();

                ResultTable.Columns.Add(new DataColumn("InternalID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Category", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Purpose", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("SubmittedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LocalCurrency", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("AmountClaimed", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("FinalAmount", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("LessCardsTransaction", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("OwningToFromEmployee", Type.GetType("System.Decimal")));
                ResultTable.Columns.Add(new DataColumn("ClaimedBy", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ClaimedByID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("CostCenter", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Status", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedDate", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LastProcessedBy", Type.GetType("System.String")));


                for (int x = 0; x < ResultObj.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();

                    GonzalesClaimHeader CurrentObj = (GonzalesClaimHeader)ResultObj[x];

                    ResultRow["InternalID"] = CurrentObj.InternalID;
                    ResultRow["ClaimID"] = CurrentObj.ClaimID;
                    ResultRow["Category"] = ClaimManager.GetClaimCategoryInString(CurrentObj.Category);
                    ResultRow["Purpose"] = CurrentObj.Reasons;
                    ResultRow["Status"] = ClaimManager.GetClaimStatusInString(CurrentObj.Status);
                    ResultRow["LocalCurrency"] = CurrentObj.LocalCurrency.InternalID;
                    ResultRow["AmountClaimed"] = CurrentObj.TotalClaimedAmount;
                    ResultRow["FinalAmount"] = CurrentObj.FinalApprovedAmount;
                    ResultRow["LessCardsTransaction"] = CurrentObj.TotalLocalAmountAlreadyPaid;
                    ResultRow["OwningToFromEmployee"] = CurrentObj.TotalLocalActualAmountLeft;
                    ResultRow["ClaimedBy"] = CurrentObj.ClaimedBy.DisplayName + " (" + CurrentObj.ClaimedBy.EmailID + ") ";
                    ResultRow["ClaimedByID"] = CurrentObj.ClaimedBy.InternalID;
                    ResultRow["EmployeeID"] = CurrentObj.ClaimedBy.EmployeeID;
                    ResultRow["CostCenter"] = CurrentObj.ClaimedBy.CostCenter;
                    //Added by Agnes [10 Nov 2009]
                    if (CurrentObj.SubmittedOn.Year > 2000)
                        ResultRow["SubmittedDate"] = SwissArmy.DateConvert(CurrentObj.SubmittedOn, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    else
                        ResultRow["SubmittedDate"] = "";

                    if (CurrentObj.LastUpdatedOn.Year > 2000)
                        ResultRow["LastProcessedDate"] = SwissArmy.DateConvert(CurrentObj.LastUpdatedOn, this.CurrentModuleSession.CurrentLoggedOnUser.PreferedDateFormat, "/");
                    else
                        ResultRow["LastProcessedDate"] = "";

                    ResultRow["LastProcessedBy"] = CurrentObj.LastUpdatedBy.DisplayName;

                    ResultTable.Rows.Add(ResultRow);
                }

            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetClaimantReportsByCompany] : CurManager.GetUsersByCompany('" + CompanyID + "') : " + CurManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion

    // Added by thangnv 20130625
    #region GetLogChangeByModule
    public DataTable GetLogChangeByModule(string EntityID, string CompanyID, DateTime SubmittedDateStart, DateTime SubmittedDateEnd)
    {
        DataTable ResultTable = null;
        using (LogManager CurLogManager = new LogManager(this.CurrentModuleSession))
        {
            LogsCollection ResultObj = CurLogManager.GetChangeLogAuthorizer(EntityID, CompanyID, SubmittedDateStart, SubmittedDateEnd);

            if (ResultObj != null)
            {
                ResultTable = new DataTable();
                ResultTable.Columns.Add(new DataColumn("Instance", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("DateTime", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LoggedBy", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("LoggedByRole", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("UserIDAffected", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EmployeeID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("EntityCode", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("CompanyID", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Module", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("ChangeField", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("Action", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("PreviousValue", Type.GetType("System.String")));
                ResultTable.Columns.Add(new DataColumn("NewValue", Type.GetType("System.String")));

                for (int x = 0; x < ResultObj.Count; x++)
                {
                    DataRow ResultRow = ResultTable.NewRow();
                    GetChangeLogItem CurrentObj = (GetChangeLogItem)ResultObj[x];

                    ResultRow["Instance"] = CurrentObj.Instance;
                    ResultRow["DateTime"] = CurrentObj.LogDate;
                    ResultRow["LoggedBy"] = CurrentObj.LoggedbyName;
                    ResultRow["LoggedByRole"] = CurrentObj.LoggedbyRole;
                    ResultRow["UserIDAffected"] = CurrentObj.UserIDAffected;
                    ResultRow["EmployeeID"] = CurrentObj.EmployeeID;
                    ResultRow["EntityCode"] = CurrentObj.EntityID;
                    ResultRow["CompanyID"] = CurrentObj.CompanyCode;
                    ResultRow["Module"] = CurrentObj.Module;
                    ResultRow["ChangeField"] = CurrentObj.ChangedField;
                    ResultRow["Action"] = CurrentObj.Action;
                    ResultRow["PreviousValue"] = CurrentObj.PreviousValue;
                    ResultRow["NewValue"] = CurrentObj.NewValue;

                    ResultTable.Rows.Add(ResultRow);
                }
            }
            else
            {
                this.ErrMsg = "[ReportsGenerator.GetLogChangeByModule] : CurLogManager.GetChangeLogAuthorizer('" + EntityID + "','" + CompanyID + "','" + SubmittedDateStart.ToString() + "', '" + SubmittedDateEnd.ToString() + "') : " + CurLogManager.ErrorMessage;
            }
        }

        return ResultTable;
    }
    #endregion

}
